package com.lx;

import com.lx.dao.UserMysqlDaoImpl;
import com.lx.service.UserService;
import com.lx.service.UserServiceImpl;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Main {
    // public static void main(String[] args) {
    //     UserService userService = new UserServiceImpl();
    //     //set方法后，程序不再具有主动性，而是被动的去接收对象
    //     ((UserServiceImpl) userService).setUserDao(new UserMysqlDaoImpl());
    //     userService.getUserDataService();
    // }

    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-bean.xml");
        UserServiceImpl userServiceImpl = (UserServiceImpl) context.getBean("userServiceImpl");
        userServiceImpl.getUserDataService();
    }
}
